//
//  DisplayTestController.m
//  JsUtilityDemo
//
//  Created by Gikki Ares on 2021/9/24.
//

#import "DisplayTestController.h"
#import <JsUtilitySdk/JsUtilitySdk.h>

@interface DisplayTestController ()<
	JsMenuViewDelegate
>

{
	JsMenuView * mMenuView;
}

@end

@implementation DisplayTestController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
	[self setupUi];
}

- (void)setupUi {
	self.view.backgroundColor = [UIColor whiteColor];
	{
	if(!mMenuView) {
		CGRect frame = [JsGeometryManager frameHAlignCenterVAlignBottomWithContainerSize:self.view.frame.size size:CGSizeMake(JsGeometryManager.screenSize.width, 300)];
		JsMenuView * mMenuView = [[JsMenuView alloc]initWithFrame:frame];
		mMenuView.delegate = self;
		[self.view addSubview:mMenuView];
	}
	}
}

#pragma mark JsMenuViewDelegate
- (NSArray<JsMenuItemVm *> *)jsMenuViewSetDatasource:(JsMenuView *)view {
	return @[
		[[JsMenuItemVm alloc]initWithTitle:@"warn"],
		[[JsMenuItemVm alloc]initWithTitle:@"info"],
		[[JsMenuItemVm alloc]initWithTitle:@"long info"],
		[[JsMenuItemVm alloc]initWithTitle:@"error"],
		[[JsMenuItemVm alloc]initWithTitle:@"success"],
		[[JsMenuItemVm alloc]initWithTitle:@"silent"],
		[[JsMenuItemVm alloc]initWithTitle:@"Long silent"],
		[[JsMenuItemVm alloc]initWithTitle:@"RotateScreen"],
		[[JsMenuItemVm alloc]initWithTitle:@"ShowLoading"]
	];
}

- (void)jsMenuView:(JsMenuView *)view clickMenuAtIndex:(int)index vm:(JsMenuItemVm *)vm {
	switch (index) {
		case 0:{
			[self.view displayMessage:@"This is warn" contentType:JsMessageReminderContentTypeWarn];
			break;
		}
		case 1:{
			[self.view displayMessage:@"This is info" contentType:JsMessageReminderContentTypeInfo];
			break;
		}
		case 2:{
			[self.view displayMessage:@"This is long long long long long long long long long long long long long long long long long long  info" contentType:JsMessageReminderContentTypeInfo];
			break;
		}
			
		case 3:{
			[self.view displayMessage:@"This is error" contentType:JsMessageReminderContentTypeError];
			break;
		}
		case 4:{
			[self.view displayMessage:@"This is success" contentType:JsMessageReminderContentTypeSuccess];
			break;
		}
		case 5: {
			[self.view displayMessage:@"This is silent" contentType:JsMessageReminderContentTypeSilent];
			break;
		}
		case 6: {
			JsDisplayStyle * style = [JsDisplayStyle defaulStyle];
			style.displayPosition = JsDisplayPositionBottom;
			style.offset_displayPosition = UIOffsetMake(0, -20);
			style.mf_displayTime = 3;
			[self.view displayMessage:@"This is silent,This is a long long long long long long long long long long long silent message" image:nil style:style];
			break;
		}
		case 7: {
			//旋转方向
			break;
		}
		case 8: {
			[self.view displayLoading];
			
			dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
				[self.view undisplayLoading];
			});
		}
		default:
			break;
	}
}





@end
